package com.hzcx.app.simplechat.ui.setting.presenter;

import android.app.Activity;
import android.content.Context;

import com.hzcx.app.simplechat.api.BaseDialogObserver;
import com.hzcx.app.simplechat.api.BaseObserver;
import com.hzcx.app.simplechat.base.BaseEmptyBean;
import com.hzcx.app.simplechat.base.BasePresenter;
import com.hzcx.app.simplechat.bean.UpLoadImgBean;
import com.hzcx.app.simplechat.model.ChatModel;
import com.hzcx.app.simplechat.model.PublicModel;
import com.hzcx.app.simplechat.model.SettingModel;
import com.hzcx.app.simplechat.model.UserModel;
import com.hzcx.app.simplechat.ui.chat.bean.ChatQuickMsgBean;
import com.hzcx.app.simplechat.ui.friend.bean.FriendBean;
import com.hzcx.app.simplechat.ui.friend.bean.FriendCityBean;
import com.hzcx.app.simplechat.ui.setting.bean.BlackListBean;
import com.hzcx.app.simplechat.ui.setting.contract.BlackListContract;
import com.hzcx.app.simplechat.ui.setting.contract.GroupMessageSendContract;
import com.hzcx.app.simplechat.util.token.TokenUtils;

import java.util.List;

public class GroupMessageSendPresenter extends BasePresenter<GroupMessageSendContract.View> implements GroupMessageSendContract.Presenter {

    /**
     * 群发消息
     *
     * @param context
     * @param type
     * @param maincontent
     * @param audio_time
     */
    @Override
    public void sendMessage(Context context,String ids, String hxUsernames, int type, String maincontent, int audio_time) {
        SettingModel.sendGroupMessage(context, ids, type, maincontent, hxUsernames, audio_time, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.sendSuccess(type,maincontent);
            }
        });
    }

    /**
     * 上传图片
     *
     * @param activity
     * @param path
     */
    @Override
    public void upLoadImg(Activity activity, String path) {
        PublicModel.upLoadImg(activity, TokenUtils.getTokenHeader(), path, new BaseDialogObserver<UpLoadImgBean>(activity) {
            @Override
            protected void onSuccess(UpLoadImgBean data) {
                mView.imgLoadSuccess(data.getUrl());
            }
        });
    }

    /**
     * 上传文件
     *
     * @param activity
     * @param path
     */
    @Override
    public void upLoadFile(Activity activity, String path) {
        PublicModel.upLoadFile(activity, path, new BaseDialogObserver<UpLoadImgBean>(activity) {
            @Override
            protected void onSuccess(UpLoadImgBean data) {
                mView.fileLoadSuccess(data.getUrl());
            }
        });
    }

    /**
     * 重新发送消息
     *
     * @param context
     * @param id
     * @param type
     * @param maincontent
     * @param audio_time
     */
    @Override
    public void reSendMessage(Context context, int id, int type, String maincontent, int audio_time) {
        SettingModel.reSendGroupMessage(context, id, type, maincontent, audio_time, new BaseDialogObserver<BaseEmptyBean>(context) {
            @Override
            protected void onSuccess(BaseEmptyBean data) {
                mView.sendSuccess(type,maincontent);
            }
        });
    }

    /**
     * 获取快捷回复列表
     *
     * @param context
     */
    @Override
    public void getChatQuickMsgList(Context context) {
        ChatModel.getChatQuickMsgList(context, new BaseObserver<List<ChatQuickMsgBean>>() {
            @Override
            protected void onSuccess(List<ChatQuickMsgBean> data) {
                mView.qucikMsgResult(data);
            }
        });
    }
}
